<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    // 快速包装一个promise实例对象
    const d1 = Promise.resolve(1)
    console.log('d1', d1); //成功状态的promise实例 值为1

    const d2 = Promise.reject(1) //失败状态的promise实例 值为1
    console.log('d2', d2);

    // 当resolve传的参数是一个promise实例时,resolve方法的返回值状态与传入的这个实例状态一致
    const d3 = Promise.reject(new Promise((resolve, reject) => {
      // resolve(1)
      reject('err')
    }))
    console.log('d3', d3);

    // 当resolve传的参数是一个promise实例时,resolve方法的返回值即为传入的promise实例整体
    const d4 = Promise.reject(new Promise((resolve, reject) => {
      resolve(1)
      // reject('err')
    }))
    console.log('d4', d4);
  </script>
</body>

</html>